home *** CD-ROM | disk | FTP | other *** search
- <?php
-
- $entry = "<i>%who%</i>%details% %time% (%ip%) %remove%<bR>%text%<br><br>";
- $result = "";
- $counter = 0;
-
- include_once("fn.php");
-
- function startElementE($parser, $name, $attrs)
- {
- if (strcmp($name,"COMMENT")==0)
- {
- global $entry;
- global $result;
- global $counter;
-
- $entrym1 = " (<a href=\"mailto:%mail%\">e-mail</a>, <a href=\"%web%\">web</a>)";
- $entrym2 = " (<a href=\"mailto:%mail%\">e-mail</a>)";
- $entrym3 = " (<a href=\"%web%\">web</a>)";
-
- $res=str_replace("%who%",charDecode($attrs['PERSON']),$entry);
- $res=str_replace("%text%",charDecode($attrs['TEXT']),$res);
- $res=str_replace("%ip%",charDecode($attrs['IP']),$res);
-
- $counter++;
- $removelnk = " <a href=\"remcmt.php?file=%fileid%&id=".$counter."\">odstranit</a>";
- $res=str_replace("%remove%",$removelnk,$res);
-
-
- $tm=$attrs['TIME'];
- if (strcmp($tm,"")!=0)
- $tm=date("d.m.Y H:i:s",$tm);
- $res=str_replace("%time%",$tm,$res);
-
- $entrym="";
- if (strcmp($attrs['MAIL'],"")!=0)
- {
- if (strcmp($attrs['WEB'],"")!=0 && strcmp($attrs['WEB'],"http://")!=0)
- $entrym=$entrym1;
- else
- $entrym=$entrym2;
- }
- else
- if (strcmp($attrs['WEB'],"")!=0 && strcmp($attrs['WEB'],"http://")!=0)
- $entrym=$entrym3;
- $resm=str_replace("%mail%",charDecode($attrs['MAIL']),$entrym);
- $resm=str_replace("%web%",charDecode($attrs['WEB']),$resm);
-
- $res=str_replace("%details%",$resm,$res);
-
- $result=$result.$res;
- }
- }
-
- function endElementE($parser, $name)
- {
- }
-
- function vshowcomments($id)
- {
- $soubor="text/%num%.cmt";
- $soubor=str_replace("%num%",$id,$soubor);
- global $result;
- global $counter;
-
- if (file_exists($soubor))
- {
- $xml_parser = xml_parser_create();
- xml_set_element_handler($xml_parser, "startElementE", "endElementE");
- if (!($fp = fopen($soubor, "r"))) {
- die("could not open XML input");
- }
-
- while ($xmldata = fread($fp, 4096)) {
- if (!xml_parse($xml_parser, $xmldata, feof($fp))) {
- die(sprintf("XML error: %s at line %d",
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
- }
- }
- xml_parser_free($xml_parser);
- }
- $result=str_replace("%fileid%",$id,$result);
- $copy=$result;
- $result="";
- $counter=0;
- return $copy;
- }
-
- $cmtcount=0;
- function startElementC($parser, $name, $attrs)
- {
- global $cmtcount;
- if (strcmp($name,"COMMENTS")==0)
- {
- $cmtcount=(int)$attrs['COUNT'];
- }
- }
-
- function vgetcommentcount($id)
- {
- $soubor="text/%num%.cmt";
- $soubor=str_replace("%num%",$id,$soubor);
- global $cmtcount;
-
- if (file_exists($soubor))
- {
- $xml_parser = xml_parser_create();
- xml_set_element_handler($xml_parser, "startElementC", "endElementE");
- if (!($fp = fopen($soubor, "r"))) {
- die("could not open XML input");
- }
-
- while ($xmldata = fread($fp, 4096)) {
- if (!xml_parse($xml_parser, $xmldata, feof($fp))) {
- die(sprintf("XML error: %s at line %d",
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
- }
- }
- xml_parser_free($xml_parser);
- }
- return $cmtcount;
- }
-
- ?>
-